<?php

namespace addons\seller\service;


class CommunitySellerRelation
{
    /**
     * 根据seller_id获取此商家的所有社区信息
     */
    static function get_seller_community_by_seller_id($seller_id,$param)
    {
        $c = new \app\common\model\CommunitySellerRelation();
        $cond = [];
        if (isset($param['search_']) && !empty($param['search_'])) {   #搜索条件
            $search_ = $param['search_'];
            $cond["shop_community.community_name"] = ["LIKE", "%$search_%"];
        }
        $data = $c
            ->field('shop_community.*')
            ->join('shop_community','shop_community_seller_relation.community_id=shop_community.id')
            ->where('shop_community_seller_relation.seller_id',$seller_id)
            ->where($cond)
            ->paginate(30,false,['query'=>request()->param()]);
        return $data;
    }

    /**
     * 获取商家已经选择的社区ids
     * @param $seller_id
     * @return array
     */
    public function  get_community_column_by_seller_id($seller_id)
    {
        $c = new \app\common\model\CommunitySellerRelation();
        $selected_community_ids = $c->where('shop_community_seller_relation.seller_id',$seller_id)->column('community_id');
        return $selected_community_ids;
    }


}
